<?php
//判断你的网站是http状态还是https状态
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
//后台配置
$config=array(
"admin"=>array(
//后台账号
"admin_user"=>"admin",
//后台密码
"admin_pass"=>"123456",
),
//网站配置
$web=array(
//网站站长QQ号
"qq"=>"3038733136",
//网站名称
"ming"=>"囍楽",
//网站关键词
"keywords"=>"API接口,聚合数据,API数据接口,免费API数据接口,API接口管理系统,免费API数据调用",
//网站描述
"description"=>"我们致力于为用户提供免费、稳定、快速的API数据接口调用服务平台！",
//网站备案号
"beian"=>"努力备案....",
//网站站长邮箱
"youxiang"=>"3038733136@qq.com",
//网站官方群号
"qun"=>"616247774",
//网站官方群链接
"qun_list"=>"https://jq.qq.com/?_wv=1027&k=*******",
//网站运行时间
"yunhang"=>"2022-04-08",
//网站模板(目前支持1-5模板)
"muban"=>"5",
//这个不用管了，接口和页面用的
"tianyi719"=>"".$http_type."".$_SERVER["HTTP_HOST"]."",
//名片赞下单接口token(网络聊天室和网络词库通用)
"mpz"=>"填写",
),
//社区配置(名片赞下单接口使用)
$mpz=array(
//社区的TokenID
"token"=>"填写",
//社区的密匙
"key"=>"填写",
//商品编号
"gid"=>"填写",
//社区地址
"domain"=>"填写",
),
);

//后台登录验证
function read_dic($list,$name,$type="text",$Ending="0")
{
	clearstatcache();
	$fp_name = "Cache/" . $list . ".txt";
	$fp = fopen($fp_name, "r");
	flock($fp, LOCK_EX);
	$fp_open = fread($fp, filesize($fp_name));
	if ($type != "text") {
		return $fp_open;
	}else{
		$encode = base64_encode($name);
		$json = json_decode($fp_open, true);
		return $json[$encode]?$json[$encode]:$Ending;
	}
	flock($fp, LOCK_UN);
	fclose($fp);
}

function write_dic($list,$name,$msg) {
	clearstatcache();
	$encode = base64_encode($name);
 	$fp_name = "Cache/" . $list . ".txt";
	$dir = dirname($fp_name);
	if(!is_dir($dir)){
		mkdir($dir, 0777, true);
	}
	$read = read_dic($list, $name, "json");
	if(!$read) {
		$json = array();
	}else{
		$json = json_decode($read, true);
	}
	$now_array = array($encode => $msg);
	$new_array = array_merge($json, $now_array);
	$new_json = json_encode($new_array);
	$fp = fopen($fp_name, "w");
	flock($fp, LOCK_EX);
	fwrite($fp, $new_json);
	flock($fp, LOCK_UN);
	fclose($fp);
}

function write_data_add($name,$qq,$moneys)
{
$money=read_dic($name,$qq,"text");
write_dic($name,$qq,($money+$moneys));
}

function write_data_remove($name,$qq,$moneys)
{
$money=read_dic($name,$qq,"text");
write_dic($name,$qq,($money-$moneys));
}


?>